/**
 * struct TreeNode {
 *	int val;
 *	struct TreeNode *left;
 *	struct TreeNode *right;
 *	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 * };
 */
class Solution {
public:
    bool IsBalanced_Solution(TreeNode* pRoot) {
        return dfs(pRoot) != -1;
    }

    int dfs(TreeNode* root)
    {
        if(root == nullptr)
            return 1;

        int left = dfs(root->left);
        if(left == -1)
            return -1;
        
        int right = dfs(root->right);
        if(right == -1)
            return -1;

        return abs(left-right) <= 1 ? max(left,right)+1 : -1;
    }
};



#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int str_len = 0;  cin >> str_len;
    string str;       cin >> str;
    
    if(str.size() % 2 != 0)
    {
        cout << 0;
        return 0;
    }
    
    // 统计原始字符串中0和1的个数
    int raw_0_count = 0;
    int raw_1_count = 0;
    for(auto e : str)
    {
        if(e == '0') raw_0_count++;
        if(e == '1') raw_1_count++;
    }
    
    int left = 0;
    int right = 0;
    int count = 0;
    int cur_0_count = 0;
    int cur_1_count = 0;
    
    while(right < str.size())
    {
        if(str[right] == '0') cur_0_count++;
        else if(str[right] == '1') cur_1_count++;
        
        if(right < (str.size() / 2 - 1))
        {
            right++;
            continue;
        }
        
        if(cur_0_count == raw_0_count && cur_1_count == raw_1_count)
        {
            count++;
        }
        
        right++;
        left++;
    }
    
    cout << count;
    
    return 0;
}